package com.ficus.road.maintain.core.model.smartnew;

import com.ficus.road.maintain.core.utils.SmartDecisionUtils;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.ObjectUtils;

import java.util.Set;

/**
 * @author xiawen yang
 * @date 2022/7/14 下午3:53
 */
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
public class SmartTable extends SmartDecisionExcelVO {
    /**
     * 总权重
     */
    protected Double totalWeight;
    /**
     * 所属类（第几大类）
     */
    private String type;
    /**
     * 权重
     */
    private Double weight;
    /**
     * 未合并前的路段id
     */
    private Set<String> unmergedIds;
    /**
     * 合并后的id
     */
    private String mergedId;

    public SmartTable(SmartDecisionExcelVO vo, String type) {
        super(vo);
        this.type = type;
        this.weight = SmartDecisionUtils.convertHighwaySmartTableType2Weight(type);
    }

    public SmartTable(String id) {
        super(id);
        this.totalWeight = 0d;
    }

    public Set<String> getUnmergedIdsOrDefault(Set<String> set) {
        return ObjectUtils.isEmpty(getUnmergedIds()) ? set : getUnmergedIds();
    }
}
